package com.example.administrator.easy.view;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.administrator.easy.R;
import com.example.administrator.easy.application.MyApplication;

import java.util.ArrayList;

/**
 * Created by Administrator on 2016/11/13.
 */

public class WodeFragment extends Fragment {
    private Toolbar tb;
    private ArrayList<Fragment> fmList;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_wode,null);
        initView();
        return  view;
    }

    private void initView() {
        fmList = new ArrayList<>();
        fmList.add(new WodeNoFragment());
        fmList.add(new WodeYiFragment());

    }
//
    @Override
    public void onResume() {
        super.onResume();
        //判断是否登录
        MyApplication a = (MyApplication) getActivity().getApplication();
        Log.e("Mainwode","isLogin"+a.isLogin());
        if(a.isLogin()){//如果已登录
            FragmentTransaction t = getChildFragmentManager().beginTransaction();
            t.add(R.id.wode_ll_fm, fmList.get(1)).hide(fmList.get(0));
            t.commit();
        }else{
            FragmentTransaction t2 = getChildFragmentManager().beginTransaction();
            t2.add(R.id.wode_ll_fm,fmList.get(0));
            t2.commit();
        }
    }
}
